package controllerTaf;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTable;

import domijn.Tafel;
import pnlRestaurant.PnlResMain;
import tblModelTafel.TMTafel;

public class TafBtnDelete implements ActionListener {
	
	private PnlResMain pnlResMain;
	private JTable table;
	@SuppressWarnings("unused")
	private TMTafel tafelM;

	public TafBtnDelete(PnlResMain pnlResMain) {
		this.pnlResMain = pnlResMain;
	}

	@Override
	public void actionPerformed(ActionEvent i) {
		if (i.getActionCommand().equals("Delete")){	 
				String nummer ;
				nummer =  pnlResMain.getTxtTafelNummerR().getText();
				System.out.println(nummer);
		
				int n = Integer.valueOf(nummer);
				Tafel tafel = new Tafel(n);
				tafel.delete();
		
				pnlResMain.getLblDeleteMelding().setVisible(true);
				pnlResMain.getLblSaveMelding().setVisible(false);
				pnlResMain.getTxtTafelNummerR().setText("");
				table = pnlResMain.getTblTafel();
				table.setModel(tafelM = new TMTafel(pnlResMain));
				table.repaint();
				table.revalidate();
		}	
	}
}